package club.kingyin.easycache.proxy;

import club.kingyin.easycache.key.InvokePostProcess;
import club.kingyin.easycache.cache.ProxyMethodCache;
import club.kingyin.easycache.method.CacheMethod;
import club.kingyin.easycache.method.MethodEasyCache;
import club.kingyin.easycache.proxy.adapter.CacheMethodKeyAdapter;

public class ProxyMethodEasyCache extends MethodEasyCache {

    private ProxyMethodCache cache;

    private InvokePostProcess<CacheMethod>[] postProcesses;

    private CacheMethodKeyAdapter cacheMethodKeyAdapter = null;

    public void setCacheMethodKeyAdapter(CacheMethodKeyAdapter cacheMethodKeyAdapter) {
        this.cacheMethodKeyAdapter = cacheMethodKeyAdapter;
    }

    public void setCache(ProxyMethodCache cache) {
        this.cache = cache;
    }

    public void setInvokePostProcesses(InvokePostProcess<CacheMethod>[] postProcesses) {
        this.postProcesses = postProcesses;
    }

    public Object proxy(Object target) {
        return CglibObjectFactory.proxyObjectFactory(target, cache, postProcesses, cacheMethodKeyAdapter);
    }

}
